<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	//生成随机数
	var ran=parseInt(Math.random()*100);
	console.log(ran);
	function cai() {
	var span=document.getElementById("result");
		var n=document.getElementById("input").value;
		console.log(n);
		if(isNaN(n)){
			span.innerHTML="请输入数字!";
		}else if(n>ran){
			span.innerHTML="大了!";
		}else if(n<ran){
			span.innerHTML="小了!";
		}else{
			span.innerHTML="对了!";
		}
	}
</script>
</head>
<body>
	
		<input type="text" id="input"/>
		<input type="button" value="猜" onclick="cai();"/>
		<span id="result"></span>
	
</body>
</html>